Direct Functions
These functions are invoked by the Image Compression Manager in direct response to application functions. Refer to the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for descriptions of the functions that applications call.
ImageCodecGetCodecInfo
Your component receives the
ImageCodecGetCodecInfo
request whenever an application calls the Image Compression Manager's
GetCodecInfo
function.
pascal ComponentResult
ImageCodec
GetCodecInfo (
ComponentInstance ci, CodecInfo *info);
-
ci
-
Specifies the component instance of the image decompressor component
-
info
-
Contains a pointer to the compressor information structure (defined by the
CodecInfo
data type) to update. Your component should report its capabilities by formatting a compressor information structure in the location specified by this parameter.
DESCRIPTION
Your component returns a formatted compressor information structure defining its capabilities.
Both compressors and decompressors may receive this request.
RESULT CODES
noErr
|
0
|
No error
|
codecUnimpError
|
-8962
|
Feature not implemented by this compressor
|
SEE ALSO
See the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for a description of the compressor information structure.
ImageCodecGetMaxCompressionSize
Your component receives the
ImageCodecGetMaxCompressionSize
request whenever an application calls the Image Compression Manager's
GetMaxCompressionSize
function. The caller uses this function to determine the maximum size the data will become for a given parameter.
pascal ComponentResult
ImageCodec
GetMaxCompressionSize (
ComponentInstance ci,
PixMapHandle src,
const Rect *srcRect,
short depth,
CodecQ quality,
long *size);
-
ci
-
Specifies the component instance of the image decompressor component
-
src
-
Contains a handle to the source image. The source image is stored in a pixel map structure. Applications use the size information you return to allocate buffers that may be used for more than one image. Consequently, your compressor should not consider the contents of the image when determining the maximum compressed size. Rather, you should consider only the quality level, pixel depth, and image size.
-
This parameter may be set to
nil
. In this case the application has not supplied a source image--your component should use the other parameters to determine the characteristics of the image to be compressed.
-
srcRect
-
Contains a pointer to a rectangle defining the portion of the source image to compress.
-
depth
-
Specifies the depth at which the image is to be compressed. Values of 1, 2, 4, 8, 16, 24, and 32 indicate the number of bits per pixel for color images. Values of 33, 34, 36, and 40 indicate 1-bit, 2-bit, 4-bit, and 8-bit grayscale, respectively, for grayscale images.
-
quality
-
Specifies the desired compressed image quality. See the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for valid values.
-
size
-
Contains a pointer to a field to receive the maximum size, in bytes, of the compressed image.
DESCRIPTION
Your component returns a long integer indicating the maximum number of bytes of compressed data that results from compressing the specified image.
Only compressors receive this request.
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
ImageCodecGetCompressionTime
Your component receives the
CDGetCompressionTime
request whenever an application calls the Image Compression Manager's
GetCompressionTime
function.
pascal ComponentResult
ImageCodec
GetCompressionTime (
ComponentInstance ci,
PixMapHandle src,
const Rect *srcRect,
short depth, CodecQ
*spatialQuality,
CodecQ *temporalQuality,
unsigned long *time);
-
ci
-
Specifies the component instance of the image decompressor component
-
src
-
Contains a handle to the source image. The source image is stored in a pixel map. Applications may use the time information you return for more than one image. Consequently, your compressor should not consider the contents of the image when determining the maximum compression time. Rather, you should consider only the quality level, pixel depth, and image size.
-
This parameter may be set to
nil
. In this case the application has not supplied a source image--your component should use the other parameters to determine the characteristics of the image to be compressed.
-
srcRect
-
Contains a pointer to a rectangle defining the portion of the source image to compress.
-
depth
-
Specifies the depth at which the image is to be compressed. Values of 1, 2, 4, 8, 16, 24, and 32 indicate the number of bits per pixel for color images. Values of 33, 34, 36, and 40 indicate 1-bit, 2-bit, 4-bit, and 8-bit grayscale, respectively, for grayscale images.
-
spatialQuality
-
Contains a pointer to a field containing the desired compressed image quality. The compressor sets this field to the closest actual quality that it can achieve. See the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for valid values. Check to see if the value of this field is
nil
and, if so, do not write to location 0.
-
temporalQuality
-
Contains a pointer to a field containing the desired sequence temporal quality. The compressor sets this field to the closest actual quality that it can achieve. See the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for valid values. Check to see if the value of this field is
nil
and, if so, do not write to location 0.
-
time
-
Contains a pointer to a field to receive the compression time, in milliseconds. If your component cannot determine the amount of time required to compress the image, set this field to 0. Check to see if the value of this field is
nil
and, if so, do not write to location 0.
DESCRIPTION
Your component returns a long integer indicating the maximum number of milliseconds it would require to compress the specified image.
-
Only compressors receive this request.
-
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
codecUnimpError
|
-8962
|
Feature not implemented by this compressor
|
ImageCodecGetSimilarity
Your component receives the
ImageCodecGetSimilarity
request whenever an application calls the Image Compression Manager's
GetSimilarity
function. Your component compares the specified compressed image to a picture stored in a pixel map and returns a value indicating the relative similarity of the two images.
Note
The
ImageCodecGetSimilarity
function is optional. If your component doesn't support it, it should return the
codecUnimpError
result code.
pascal ComponentResult
ImageCodec
GetSimilarity (ComponentInstance ci,
PixMapHandle src,
const Rect *srcRect,
ImageDescriptionHandle desc,
Ptr data,
Fixed *similarity);
-
ci
-
Specifies the component instance of the image decompressor component
-
src
-
Contains a handle to the noncompressed image. The image is stored in a pixel map structure.
-
srcRect
-
Contains a pointer to a rectangle defining the portion of the image to compare to the compressed image.
-
desc
-
Contains a handle to the image description structure that defines the compressed image for the operation.
-
data
-
Contains a pointer to the compressed image data.
-
similarity
-
Contains a pointer to a field that is to receive the similarity value. Your component sets this field to reflect the relative similarity of the two images. Valid values range from 0 (key frame) to 1 (identical).
DESCRIPTION
If the source image has been temporally compressed and is not a key frame (that is, the image relies on other frames that are not available to your component at this time), your component should return a result value of
paramErr
.
Only decompressors receive this request.
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
memFullErr
|
-108
|
Not enough memory available
|
codecUnimpError
|
-8962
|
Feature not implemented by this compressor
|
ImageCodecGetCompressedImageSize
Your component receives the
ImageCodecGetCompressedImageSize
request whenever an application calls the Image Compression Manager's
GetCompressedImageSize
function.
You can use the
ImageCodecGetCompressedImageSize
function when you are extracting a single image from a sequence; therefore, you don't have an image description structure and don't know the exact size of one frame. In this case, the Image Compression Manager calls the component to determine the size of the data.
pascal ComponentResult ImageCodecGetCompressedImageSize
(ComponentInstance ci,
ImageDescriptionHandle desc,
Ptr data,
long bufferSize,
ICMDataProcRecordPtr dataProc,
long *dataSize);
-
ci
-
Specifies the component instance of the image decompressor component
-
desc
-
Contains a handle to the image description structure that defines the compressed image for the operation.
-
data
-
Points to the compressed image data.
-
bufferSize
-
Specifies the size of the buffer to be used by the data-loading function specified by the
dataProc
parameter. If the application did not specify a data-loading function this parameter is
nil
.
-
dataProc
-
Points to a data-loading function structure. If the data stream is not all in memory when the application calls
GetCompressedImageSize
, your component may call an application function that loads more compressed data (see the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for more information about data-loading functions). This parameter contains a pointer to a structure that identifies the data-loading function. If the application did not provide a data-loading function, this parameter is
nil
. In this case, the entire image must be in memory at the location specified by the
data
parameter.
-
dataSize
-
Contains a pointer to a field that is to receive the size, in bytes, of the compressed image.
DESCRIPTION
Your component returns a long integer indicating the number of bytes of data in the compressed image. You may want to store the image size somewhere in the image description structure, so that you can respond to this request quickly. See the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for more information about image description structures.
Only decompressors receive this request.
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
codecSpoolErr
|
-8966
|
Error loading or unloading data
|
ImageCodecTrimImage
Your component receives the
ImageCodecTrimImage
request whenever an application calls the
TrimImage
function. Your component adjusts a compressed image to the boundaries defined by a rectangle specified by your application. The resulting image data is still compressed and is in the same compression format as the source image.
Note
The
ImageCodecTrimImage
function is optional. If your component doesn't support it, it should return the
codecUnimpError
result code.
pascal ComponentResult
ImageCodec
TrimImage (ComponentInstance ci,
ImageDescriptionHandle desc,
Ptr inData,
long inBufferSize,
DataProcRecordPtr dataProc,
Ptr outData,
long outBufferSize,
FlushProcRecordPtr flushProc,
Rect *trimRect,
ProgressProcRecordPtr progressProc);
-
ci
-
Specifies the component instance of the image decompressor component
-
desc
-
Contains a handle to the image description structure that describes the compressed image. Your component updates this image description to refer to the resized image.
-
inData
-
Points to the compressed image data. If the entire compressed image cannot be stored at this location, the application may provide a data-loading function (see the description of the
dataProc
parameter to this function for details). This is a 32-bit clean address.
-
inBufferSize
-
Specifies the size of the buffer to be used by the data-loading function specified by the
dataProc
parameter. If the application did not specify a data-loading function, this parameter is
nil
.
-
dataProc
-
Points to a data-loading function structure. If the data stream is not all in memory when the application calls the Image Compression Manager's
GetCompressedImageSize
function, your component may call an application function that loads more compressed data (see the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for more information about data-loading functions). This parameter contains a pointer to a structure that identifies the data-loading function. If the application did not provide a data-loading function, this parameter is
nil
. In this case, the entire image must be in memory at the location specified by the
inData
parameter.
-
outData
-
Points to a buffer to receive the trimmed image. If there is not sufficient memory to store the compressed image, the application may choose to write the compressed data to mass storage during the compression operation. The
flushProc
parameter identifies the data-unloading function. This is a 32-bit clean address.
-
Your component should place the actual size of the resulting image into the
dataSize
field of the image description referred to by the
desc
parameter.
-
outBufferSize
-
Specifies the size of the buffer to be used by the data-unloading function specified by the
flushProc
parameter. If the application did not specify a data-unloading function, this parameter is
nil
.
-
flushProc
-
Points to a data-unloading function structure. If there is not enough memory to store the compressed image, your component may call an application function that unloads some of the compressed data (see the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for more information about data-unloading functions). This parameter contains a pointer to a structure that identifies that data-unloading function. If the application did not provide a data-unloading function, this parameter is
nil
. In this case, your component writes the entire compressed image into the memory location specified by the
outData
parameter.
-
trimRect
-
Contains a pointer to a rectangle that defines the desired image dimensions. Your component adjusts the rectangle values so that they refer to the same rectangle in the resulting image (this is necessary whenever data is removed from the beginning of the image).
-
progressProc
-
Points to a progress function structure. During the operation, your component should occasionally call an application function to report its progress (see the chapter "Image Compression Manager" in
Inside Macintosh: QuickTime
for more information about progress functions). This parameter contains a pointer to a structure that identifies that progress function. If the application did not provide a progress function, this parameter is
nil
.
DESCRIPTION
Only decompressors receive this request. If the
TrimImage
function has been called by an application, the resulting picture should be modified.
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
memFullErr
|
-108
|
Not enough memory available
|
noCodecErr
|
-8961
|
Image Compression Manager could not find the specified compressor
|
codecUnimpErr
|
-8962
|
Feature not implemented by this compressor
|
codecSpoolErr
|
-8966
|
Error loading or unloading data
|
codecAbortErr
|
-8967
|
Operation aborted by the progress function
|
ImageCodecBusy
Your component receives the
CDCodecBusy
request whenever an application calls the
CDSequenceBusy
function. Your component must report whether it is performing an asynchronous operation.
pascal ComponentResult
ImageCodec
Busy (ComponentInstance ci, ImageSequence seq);
-
ci
-
Specifies the component instance of the image decompressor component
-
seq
-
Contains the unique sequence identifier assigned by the Image Compression Manager's
CompressSequenceBegin
or
DecompressSequenceBegin
function.
DESCRIPTION
Your component should return a result code value of 1 if an asynchronous operation is in progress; it should return a result code value of 0 if the component is not performing an asynchronous operation. You can indicate an error by returning a negative result code.
Both compressors and decompressors may receive this request.
RESULT CODES
noErr
|
0
|
No error
|
codecUnimpError
|
-8962
|
Feature not implemented by this compressor
|
© 1999 Apple Computer, Inc.Previous | Overview | Contents | Next